<!-- 项目管理 -->
<template>
  <div class="page-box h100 display-flex czbj">
    <p class="title-label mb10">阶级任务</p>
    <!-- sonRouter="yybureauFormationBJ" 为跳转新的页面编辑 -->
    <dxtable
      :dataJson="dataJson"
      :portUrl="portUrl"
      :formJson="formJson"
      :qx="qx"
      ref="databale"
    ></dxtable>
  </div>
</template>
<script lang="ts" setup>
import dxtable from "../../components/util/dxtable.vue";
import sort from "../../components/util/sort.vue";
import { dxget, dxpost } from "../../util/index";
import { NButton, NImage, NTag } from "naive-ui";
import { h, ref, reactive, render } from "vue";
const xmlxSelect = ref([]);
const databale = ref();
const initeer = () => {
  databale.value.initDataExpose();
};
let dataJson = [
  {
    title: "痛点类型",
    key: "fid",
    type: "select",
    search: true,
    options: [],
    width:105,
    render: (row) => {
      try {
        return xmlxSelect.value.filter((a) => a.value == row.fid)[0].label;
      } catch (e) {}
    },
  },
  {
    title: "任务名称",
    key: "name",
    search: true,
  },{
    title: "奖励积分",
    key: "jifen",
    width:105,
  },
  {
    title: "排序",
    width: 100,
    render: (row) => {
      row.sjk = "xtgx"; //数据库
      row.databaseName = "keyEnterprise"; //表名
      return h(sort, {
        row,
        onCallBack: () => {
          initeer();
        },
      });
    },
  },
  {
    title: "添加时间",
    key: "addTime",
    width: 150,
  },
];

const qx = {
  DeletePermissionID: "mayajiejidel", //删除
  EditPermissionIdentifier: "mayajiejibj", // 编辑
  NewPermissionIdentifier: "mayajiejixz", // 新建
  ViewPermissionID: "mayajiejick", // 查看
};
const portUrl = "maya/jieji/jieji";

let formJson = reactive([
  {
    title: "痛点类型",
    type: "select",
    options: [],
    span: 12,
    key: "fid",
    width: "",
    search: false,
    istable: true,
    required: true,
  },
  {
    title: "任务名称",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 24,
    key: "name",
    width: "",
    search: false,
    istable: true,
    required: true,
  },
  {
    title: "奖励积分",
    key: "jifen",
    type: "input",
    required: true,
  }
]);
const czFun = {
  fun: (row) => {
    return [
      h(
        NButton,
        {
          type: "info",
          quaternary: true,
          onClick: async (e) => {},
        },
        "复制代码"
      ),
    ];
  },
};

// 获取字典内容
const xtgxxmfl = async () => {
  const { data }: any = await dxget("dxgjAdmin/getzd", {
    name: "mayatongdian",
  });
  dataJson[0].options = [
    {
      label: "全部",
      value: "",
    },
    ...data,
  ];
  formJson[0].options = data;
  xmlxSelect.value = data;
  console.log(data);
};
xtgxxmfl();
</script>
<style scoped></style>
